package com.bosicloud.cmb.ibp.api.manager.commom.constant;

/**
 * stage状态
 *
 * @author Jack Peng / ziliang.bosicloud.com
 */
public class StageStatus {

    private static String[] STS = {"PENDING", "DEPLOYING", "SUCCESS", "FAIL"};

    /**
     * 准备中
     */
    public static final String PENDING = STS[0];

    /**
     * 部署中
     */
    public static final String DEPLOYING = STS[1];

    /**
     * 已部署(测试、生产部署)
     */
    public static final String SUCCESS = STS[2];

    /**
     * 部署失败
     */
    public static final String FAIL = STS[3];

    public static class Utils {


        /**
         * 当前状态
         *
         * @param currentStatus
         */
        public static String nextStatus(String currentStatus) {

            int cur = 0;
            if (SUCCESS.equalsIgnoreCase(currentStatus) || FAIL.equalsIgnoreCase(currentStatus)) {
                return currentStatus;
            }
            for (int i = 0; i < STS.length; i++) {
                if (STS[i].equals(currentStatus)) {
                    cur = i;
                    break;
                }
            }

            return STS[cur + 1];
        }


    }

}
